define(function (require,exports,module){
	require('jtemplate');
	require('jdialog');
	common = require('common');

	exports.init = function(){

		$(".js-delete").click(function(){
			var id = $(this).attr('data-id');
			layer.confirm('确定要删除吗',['确定','取消'],function(){
				layer.load();
				$.post(exports.deleteUrl,{id:id},function(data){
					layer.closeAll('loading');
					if(data.code == 0 || data.code=='success'){
						layer.msg('删除成功');
						document.location.reload();
					}else{
						layer.msg(data.message);
					}
				},'json');
			});
		});

		$(".js-ignore").click(function(){
			var id = $(this).attr('data-id');
			layer.confirm('确定要忽略吗',['确定','取消'],function(){
				layer.load();
				$.post('do_ignore',{ids:id},function(data){
					layer.closeAll('loading');
					if(data.code == '000' || data.code=='success'){
						layer.msg('忽略成功');
						document.location.reload();
					}else{
						layer.msg(data.message);
					}
				},'json');
			});
		});
		/*旧版批量操作*/
		/*$('select[name=action-bacth-select]').change(function (e) {

			if (!common.hasChecked) return;
			e.stopPropagation();

			var actionName=$(this).children('option:selected').val();


		});*/
		/*新版批量操作*/
		$(".inner-container [data-act='operateAll']").on("click","a",function(e){
			if (!common.hasChecked) return;
			e.stopPropagation();
			var actionName=$(this).data("action");
			switch(actionName){
				case 'deleteNew':common.list_bacth_delete();break;
				case 'ignore':exports.list_bacth_ignore();break;
				
			}
		});
	};
    //批量忽略
	exports.list_bacth_ignore=function(){
		var urlpathinfo = document.location.pathname.split('/');
		var url = '/' + urlpathinfo[1] + '/' + urlpathinfo[2] + '/do_ignore';
		var __confirm = JDialog.win.work({
			title: "忽略",
			width: 340,
			height: 180,
			borderWidth: 8,
			lock: true,
			effect: 0,
			content: '<div style="padding-top: 15px;">确定要批量忽略这些消息吗？</div>',
			icon: 'warn',
			button: {
				'确认': function () {
					$.post(url, $("#J_List_Form").serialize(), function (data) {
						__confirm.close();
						if (data.code == "000") {
							JDialog.tip.work({type: "ok", content: data.message, timer: 1000});
							setTimeout(function () {
								location.reload();
							}, 1000)
						} else {
							JDialog.tip.work({type: "error", content: data.message, timer: __global.jdialog.timer});
						}
					}, "json");
				},
				'取消': function () {
					__confirm.close();
				}
			}

		});


	};
});
